// var i;
// var $gameGlobalVariable = require("./GameGlobalVariable");
// var s = cc._decorator;
// var l = s.ccclass;
// var u =
//     (s.property,
//     (function (e) {
//         function t() {
//             return (null !== e && e.apply(this, arguments)) || this;
//         }
//         __extends(t, e);
//         t.prototype.onLoad = function () {
//             var e = cc.winSize.width;
//             var t = cc.winSize.height;
//             console.log("平板 宽度=" + e, "高度=" + t);
//             var o = this.node.getComponent(cc.Canvas);
//             if (t / e < 1334 / 750) {
//                 o.fitHeight = !0;
//                 o.fitWidth = !1;
//                 $gameGlobalVariable.GameGlobalVariable.isPad = !0;
//                 console.log("平板 宽度 适配后 宽度=" + cc.winSize.width, "高度=" + cc.winSize.height);
//             } else {
//                 $gameGlobalVariable.GameGlobalVariable.isPad = !1;
//                 o.fitHeight = !1;
//                 o.fitWidth = !0;
//                 console.log("手机");
//             }
//         };
//         t.prototype.start = function () {};
//         t.prototype.checkIsMiniGame = function () {};
//         return __decorate([l], t);
//     })(cc.Component));
// exports.default = u;

import { GameGlobalVariable } from './GameGlobalVariable';

const { ccclass, property } = cc._decorator;

/**
 * 建议类名: DeviceAdapter
 */
@ccclass
export default class IPadAdapter extends cc.Component {
    /** 
     * 当组件加载时调用  
     * 建议方法名: handleOnLoad 
     */ 
    onLoad() { 
        // 获取当前屏幕的宽度和高度 
        const screenWidth = cc.winSize.width; 
        const screenHeight = cc.winSize.height; 
        console.log(`平板 宽度=${screenWidth}`, `高度=${screenHeight}`);

        // 获取Canvas组件
        const canvasComponent = this.node.getComponent(cc.Canvas);
        if (canvasComponent) {
            // 高宽比小于1334/750则认为是平板，进行高适配宽不适配
            if (screenHeight / screenWidth < 1334 / 750) {
                canvasComponent.fitHeight = true;
                canvasComponent.fitWidth = false;
                GameGlobalVariable.isPad = true;
                console.log(`平板 适配后 宽度=${cc.winSize.width}`, `高度=${cc.winSize.height}`);
            } else {
                // 否则认为是手机，进行宽适配高不适配
                GameGlobalVariable.isPad = false;
                canvasComponent.fitHeight = false;
                canvasComponent.fitWidth = true;
                console.log("手机");
            }
        }
    }

    /** 
     * 当组件开始时调用  
     * 建议方法名: handleStart 
     */ 
    start() { }

    /** 
     * 检查是否是小游戏  
     * 建议方法名: verifyIsMiniGame 
     */ 
    checkIsMiniGame() {}
}